cwd=$(shell pwd)
src_path=source
tst_path=unittest

pub=public
cnf=cloud.json
web=wwwroot
kill=kill.sh
ssl_crt=cloud.cert.pem
ssl_key=cloud.prikey.pem

cnf_aim=$(pub)/$(cnf)
web_aim=$(pub)/$(web)
crt_aim=$(pub)/$(ssl_crt)
key_aim=$(pub)/$(ssl_key)
kill_aim=$(pub)/$(kill)

install_aim=cloudd
install_dst=/
ubuntu_serice=cloudd.service

.PHONY:bin test pub_aim clean install

bin:
	@cd $(src_path) && make 

test:
	@cd $(tst_path) && make

pub_aim:$(pub) $(cnf_aim) $(web_aim) $(crt_aim) $(key_aim) $(kill_aim)
	@cd $(src_path) && make public

clean:
	@cd $(src_path) && make clean
	@cd $(tst_path) && make clean
	rm -rf $(pub)
	sudo rm -rf $(install_aim) $(install_dst)$(install_aim)

install:
	sudo cp -r $(ubuntu_serice) /etc/systemd/system/
	sudo cp -r $(pub) $(install_aim)
	sudo mv    $(install_aim) $(install_dst)

$(pub):
	mkdir -p $(pub)
$(cnf_aim):
	cp -r $(cwd)/$(cnf) $(pub)
$(web_aim):
	cp -r $(cwd)/$(web) $(pub)
$(kill_aim):
	cp -r $(cwd)/$(kill) $(pub)
$(crt_aim):
	cp -r $(cwd)/$(ssl_crt) $(pub)
$(key_aim):
	cp -r $(cwd)/$(ssl_key) $(pub)


.PHONY:towin tolinux

project=~/Project/cloud

lnx_user=yyx
lnx_addr=47.101.68.49
win_user=w3395
win_addr=192.168.2.14
lnx_dst=/home/yyx
win_dst=D:\\

towin:
	scp -r $(project) $(win_user)@$(win_addr):$(win_dst)

tolinux:
	scp -r $(project) $(lnx_user)@$(lnx_addr):$(lnx_dst)

